package com.hermes.biz.manager.user.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import com.hermes.biz.common.model.result.UserCommentResultDO;
import com.hermes.biz.common.model.user.UserCommentDO;
import com.hermes.biz.dao.user.UserCommentDAO;
import com.hermes.biz.dao.user.impl.UserCommentDAOImpl;
import com.hermes.biz.manager.user.UserCommentManager;

public class UserCommentManagerImpl implements UserCommentManager {

	private UserCommentDAO userCommentDAO;
	
	private Logger log = Logger.getLogger(UserCommentManagerImpl.class);

	public void saveUserCommentInfo(UserCommentDO userCommentDO) {

		this.userCommentDAO.saveUserCommentInfo(userCommentDO);

	}

	public List<UserCommentDO> getUserCommentInfo(long userId) {

		List<UserCommentDO> userCommentDOs = this.userCommentDAO.getUserCommentInfo(userId);

		return userCommentDOs;
	}

	public List<UserCommentDO> getUserCommentInfoByItemId(long itemId) {
		
		List<UserCommentDO> userCommentDOs = this.userCommentDAO.getUserCommentInfoByItemId(itemId);
		
		//log.error("getComments-size:"+userCommentDOs.size());
		
		if(userCommentDOs==null){
			return new ArrayList<UserCommentDO>();
		}
		
		return userCommentDOs;
	}

	public UserCommentResultDO getUserCommentInfoByCommentId(long commentId) {
		UserCommentResultDO userCommentResultDO =new  UserCommentResultDO(false);
		UserCommentDO userCommentDO = this.userCommentDAO.getUserCommentInfoByCommentId(commentId);
		if(userCommentDO!=null){
			userCommentResultDO.setModule(userCommentDO);
			userCommentResultDO.setSuccess(true);
		}
		return userCommentResultDO;
	}

	public void deleteUserCommentInfo(long userId) {
		
		this.userCommentDAO.deleteUserCommentInfo(userId);

	}

	public void deleteUserCommentInfoByCommentId(long commentId) {

		this.userCommentDAO.deleteUserCommentInfoByCommentId(commentId);

	}

	public void deleteUserCommentInfoByitemId(long itemId) {

		this.userCommentDAO.deleteUserCommentInfoByitemId(itemId);
		
	}
	public void setUserCommentDAO(UserCommentDAO userCommentDAO) {
		this.userCommentDAO = userCommentDAO;
	}

	public List<UserCommentDO> getUserCommentInfoByItemIdV2(long itemId) {
		List<UserCommentDO> userCommentDOs = this.userCommentDAO.getUserCommentInfoByItemIdV2(itemId);
		//log.error("getComments-size:"+userCommentDOs.size());
		return userCommentDOs;
	}

}
